import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    home: Scaffold(
      appBar: AppBar(
        title: const Text("Event And Notification Widget Demo"),
      ),
      body: const DragVerticalWidget(),
    ),
  ));
}

class DragVerticalWidget extends StatefulWidget {
  const DragVerticalWidget({Key? key}) : super(key: key);

  @override
  _DragVerticalWidgetState createState() => _DragVerticalWidgetState();
}

class _DragVerticalWidgetState extends State<DragVerticalWidget>
     {
  double _top = 0.0; //距顶部的偏移

  @override
  Widget build(BuildContext context) {
    return Stack(
      children: <Widget>[
        Positioned(
          top: _top,
          child: GestureDetector(
            child: CircleAvatar(
              child: const Text('A'),
            ),
            onVerticalDragUpdate: (DragUpdateDetails details) {
              setState(() => _top += details.delta.dy);
            },
          ),
        ),
      ],
    );
  }

}
